Example: Using the JSON Web Token SL Library
Product: CODESYS IIOT Libraries SL
The JSON Web Token SL Example.project
sample project, which includes a visualization to create a JWT (JSON Web Token) on a controller, shows how to use the JSON Web Token SL library.
Parameters
Internal memory has to be reserved in order to create a JWT. For this purpose, the amount of reserved memory has to be at least the size of the JWT. The maximum size can be changed in the Library Manager by means of a parameter list of the library (see Image 1).

Create a private key.
A private key is required for the asymmetric signature algorithm (RS256).
To do this, you first need to install the CODESYS Security Agent add-on.
After that, you can use the Security Screen to create a new certificate on the device.
The
Common Name
of the certificate is then passed to the JWT library.
Download the project to a controller and start the application.
Description
The JSON Web Token SL library contains a function block to create a JWT (JSON Web Token) on the controller. For this purpose, the HS256, HS384, HS512, and RS256 algorithms are supported.
Application: JWT
For symmetric signature algorithms (HS256, HS384, HS512):
Use the
sSecret
input.Leave the
sUseCaseName
andsCommanName
inputs blank.
For asymmetric signature algorithms (RS256):
Specify the data of the certificate in the
sUseCaseName
andsCommanName
inputs.Leave the
sSecret
input blank.
Visualization of the JWT
example

System requirements and restrictions
Programming system | CODESYS Development System (version 3.5.18.0 or higher) |
Runtime system | CODESYS Control Win (version 3.5.18.0) |
Add-on components | - |
Note
DOWNLOAD projects